#ifndef __KEY_H__
#define __KEY_H__

#include <REGX52.H>

void Delay()		//@11.0592MHz
{
	unsigned char i, j;

	i = 36;
	j = 217;
	do
	{
		while (--j);
	} while (--i);
}



unsigned char Key()
{
	unsigned char KeyNumber=0;
	
	if(P3_4==0){Delay();while(P3_4==0);Delay();KeyNumber=1;}
	if(P3_5==0){Delay();while(P3_5==0);Delay();KeyNumber=2;}
	if(P3_6==0){Delay();while(P3_6==0);Delay();KeyNumber=3;}
	
	if(P3_0==0){Delay();while(P3_0==0);Delay();KeyNumber=1;}
	if(P3_1==0){Delay();while(P3_1==0);Delay();KeyNumber=2;}
	if(P3_3==0){Delay();while(P3_3==0);Delay();KeyNumber=3;}

	return KeyNumber;
}

#endif
